package com.hwq.mynavigation;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TwoFragment extends Fragment {


    public TwoFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       View view =  inflater.inflate(R.layout.fragment_two, container, false);
        //未采用safe args的接收方式
        Bundle bundle = getArguments();
        if(bundle != null)
        {
            String userName = bundle.getString("user_name");
            int age = bundle.getInt("age");
            TextView tvSub = view.findViewById(R.id.tvSub);
            tvSub.setText(userName + age);
        }
        return view;

    }
}